import moment from 'moment'
const RUNTIME_MAP = {
  0: '未开始',
  1: '进行中',
  2: '已结束'
}

const RUNTIME_STATUS_MAP = {
  0: 'warning',
  1: 'processing',
  2: 'error'
}

export default {
  methods: {
    getRunTime (atime, etime) {
      const currentTime = new Date()
      const isNoneStart = moment(currentTime).isBefore(atime)
      const isEnd = moment(etime).isBefore(currentTime)
      if (isNoneStart) {
        return 0
      } else if (isEnd) {
        return 2
      } else {
        return 1
      }
    },
    runTimeDisplay (status) {
      return RUNTIME_MAP[status]
    },
    runTimeStatus (status) {
      return RUNTIME_STATUS_MAP[status]
    }
  }
}
